package com.loiot.baqi.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.loiot.baqi.controller.response.Pager;
import com.loiot.baqi.dao.WeiAccountQqGroupLeaderDao;
import com.loiot.baqi.service.WeiAccountQqGroupLeaderService;
import com.loiot.baqi.pojo.WeiAccountQqGroupLeader;


/**
 * qq群主 逻辑类。
 * 
 * @author  xuyb 
 * @creation 2016-08-28
 */
@Service("weiAccountQqGroupLeaderService")
@Transactional
public class WeiAccountQqGroupLeaderService{
    
    private Logger log = LoggerFactory.getLogger(this.getClass());
    
    @Resource
	private WeiAccountQqGroupLeaderDao weiAccountQqGroupLeaderDao;
	
	
	 /**
     * 查询 qq群主列表分页
     * 
     * @param name qq群主名称
     * @param pageIndex 页索引
     * @return
     */
    public Pager<WeiAccountQqGroupLeader> queryWeiAccountQqGroupLeaderListPage(HashMap<String,Object> pMap, int pageIndex)throws Exception {

        // 查询qq群主列表总条数
        int totalResults = weiAccountQqGroupLeaderDao.getWeiAccountQqGroupLeaderListCount(pMap);

        // 构造一个分页器
        Pager<WeiAccountQqGroupLeader> pager = new Pager<WeiAccountQqGroupLeader>(totalResults, pageIndex);
          //accountID
        // 查询qq群主列表
        List<WeiAccountQqGroupLeader> weiAccountQqGroupLeaderList = weiAccountQqGroupLeaderDao.queryWeiAccountQqGroupLeaderList(pMap, pager.getSkipResults(),
                pager.getMaxResults());
        pager.setData(weiAccountQqGroupLeaderList);
        return pager;
    }
    
    
    
    
    /**
     * 查询 qq群主（假）分页
     * 
     * @param name qq群主名称
     * @param pageIndex 页索引
     * @return
     */
    public Pager<WeiAccountQqGroupLeader> queryFlasePageList(HashMap<String,Object> pMap, int pageIndex)throws Exception {
    	//假分页
    	Pager<WeiAccountQqGroupLeader> pager = this.setPkList(pMap,pageIndex);
    	List<WeiAccountQqGroupLeader> weiAccountQqGroupLeaderList = weiAccountQqGroupLeaderDao.queryWeiAccountQqGroupLeaderList(pMap);
        pager.setData(weiAccountQqGroupLeaderList);
        return pager;
    }
    
    /**
     * 设置 假分页id集合到Map中
     * @param pMap
     * @param pageIndex
     * @return
     * @throws Exception
     */
    public Pager<WeiAccountQqGroupLeader> setPkList(HashMap<String,Object> pMap,int pageIndex) throws Exception{
    	  // 查询职位匹配信息列表总条数
        List<WeiAccountQqGroupLeader> list = weiAccountQqGroupLeaderDao.queryWeiAccountQqGroupLeaderList(pMap);
        // 构造一个分页器
        Pager<WeiAccountQqGroupLeader> pager = new Pager<WeiAccountQqGroupLeader>(list.size(), pageIndex, 5,list);
        List<WeiAccountQqGroupLeader> idsList = pager.getCurrentPageData();
        List<Long> ids =this.getIds(idsList);
        pMap.put("ids", ids);
        return pager;
    }
	
	 /**
     * 添加 qq群主
     * 
     * @param p 参数对象
     */
    public WeiAccountQqGroupLeader addWeiAccountQqGroupLeader(WeiAccountQqGroupLeader p)throws Exception {
       return  weiAccountQqGroupLeaderDao.addWeiAccountQqGroupLeader(p);
    }
    
    /**
     * 修改 qq群主
     * 
     * @param p 参数对象
     */
    public void updateWeiAccountQqGroupLeader(WeiAccountQqGroupLeader p)throws Exception {
        weiAccountQqGroupLeaderDao.updateWeiAccountQqGroupLeader(p);
    }
    
    /**
     * 修改 qq群主
     * 
     * @param p 参数对象
     */
    public void updateWeiAccountQqGroupLeader(HashMap<String,Object> pMap)throws Exception {
        weiAccountQqGroupLeaderDao.updateWeiAccountQqGroupLeader(pMap);
    }
    
    /**
     * 删除  qq群主
     * 
     * @param id 主键
     */
    public void deleteWeiAccountQqGroupLeader(java.util.Date id)throws Exception {
        weiAccountQqGroupLeaderDao.deleteWeiAccountQqGroupLeader(id);
    }
    
    /**
     * 删除  qq群主
     * 
     * @param id 主键
     */
    public void deleteWeiAccountQqGroupLeader(WeiAccountQqGroupLeader p)throws Exception {
        weiAccountQqGroupLeaderDao.deleteWeiAccountQqGroupLeader(p);
    }
    
    /**
     * 获得  qq群主
     * 
     * @param id qq群主Id
     * 
     * @return 返回与ID匹配的qq群主
     */
    public WeiAccountQqGroupLeader getWeiAccountQqGroupLeaderById(java.util.Date id)throws Exception {
        return  weiAccountQqGroupLeaderDao.getWeiAccountQqGroupLeaderById(id);
    }
    
    /**
     * 获得  qq群主
     * 
     * @param id qq群主Id
     * 
     * @return 返回与ID匹配的qq群主
     */
    public WeiAccountQqGroupLeader getWeiAccountQqGroupLeaderById(java.util.Date id,Long accountId)throws Exception {
        return  weiAccountQqGroupLeaderDao.getWeiAccountQqGroupLeaderById(id,accountId);
    }
    
    
    /**
     * 获得  qq群主
     * 
     * @param id qq群主Id
     * 
     */
    public WeiAccountQqGroupLeader getWeiAccountQqGroupLeader(HashMap<String,Object> pMap)throws Exception {
    	return (WeiAccountQqGroupLeader) weiAccountQqGroupLeaderDao.getWeiAccountQqGroupLeader(pMap);
    }
    /**
     * 获得  qq群主
     * 
     * @param name qq群主名称
     * 
     * @return 返回与NAME匹配的qq群主
     */
    public WeiAccountQqGroupLeader getWeiAccountQqGroupLeaderByName(String name)throws Exception {
        return  weiAccountQqGroupLeaderDao.getWeiAccountQqGroupLeaderByName(name);
    }
    
    /**
     * 查询 qq群主列表
     * @return qq群主列表
     */
    public List<WeiAccountQqGroupLeader> queryWeiAccountQqGroupLeaderList(HashMap<String,Object> pMap)throws Exception {
        return  weiAccountQqGroupLeaderDao.queryWeiAccountQqGroupLeaderList(pMap);
    }
    
    /**
     * 查询 qq群主列表
     * @return qq群主列表
     */
    public List<WeiAccountQqGroupLeader> queryWeiAccountQqGroupLeaderList(WeiAccountQqGroupLeader p)throws Exception {
        return  weiAccountQqGroupLeaderDao.queryWeiAccountQqGroupLeaderList(p);
    }
    
    /**
     * 查询  qq群主列表条数
     * 
     * @param name qq群主名称
     * @return qq群主列表条数
     */
    
    public int getWeiAccountQqGroupLeaderListCount(HashMap<String,Object> pMap)throws Exception {
        return  weiAccountQqGroupLeaderDao.getWeiAccountQqGroupLeaderListCount(pMap);
    }
    
    /**
     * 查询id集合
     * @return
     */
    public List<Long> getIds(List<WeiAccountQqGroupLeader> list) {
    	List<Long> idsList = null;
        if(list!=null && list.size()>0) {
        	idsList = new ArrayList<Long>();
        	for (WeiAccountQqGroupLeader b : list) {
            	idsList.add(null);
            }
        }
        return idsList;
    }
    
    /**
     * 统计 qq群主列表
     * 
     * @return qq群主列表
     */
    public List<HashMap<String,Object>> statisticsWeiAccountQqGroupLeaderInfo(HashMap<String, Object> pMap )throws Exception {
    	return  weiAccountQqGroupLeaderDao.statisticsWeiAccountQqGroupLeaderInfo(pMap);
    }
}
